<?php defined('BASEPATH') OR exit('No direct script access allowed');

/**
 * Compress HTML output
 *
 * Compress the HTML output, with this rules:
 * - Replace end of line by a space;
 * - Strip whitespaces after tags, except space;
 * - Strip whitespaces before tags, except space;
 * - Shorten multiple whitespace sequences.
 *
 * @see http://site.com
 * @version 1.0
 */
function compress() {
  $CI =& get_instance();
  $buffer = $CI->output->get_output();
  $search = array('/\n/', '/\>[^\S ]+/s', '/[^\S ]+\</s', '/(\s)+/s');
  $replace = array(' ', '>', '<', '\\1');
  $buffer = preg_replace($search, $replace, $buffer);
  $CI->output->set_output($buffer);
  $CI->output->_display();
}

/* End of file compress.php */
/* Location: ./system/application/hooks/compress.php */